package com.example.forhelp;

import android.content.ComponentName;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {

    private Button button;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
        button = findViewById(R.id.button);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {








                Intent intent = new Intent();
                intent.setAction("Help");//广播类型
                intent.putExtra("info", "help！help.....");
                //intent.setComponent( new ComponentName( "com.example.forhelp" ,"com.example.forhelp.MainActivity") );
                //sendBroadcast(intent); //发送广播
                //发送有序广播
                sendOrderedBroadcast(intent,null);
                Log.i("msg","help help help");
            }
        });

    }

    private void initView() {
        button = (Button) findViewById(R.id.button);

        button.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.button:

                break;
        }
    }
}
